<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="../../common/tagInclude.jsp" %>
<%@include file="../../common/headerInclude.jsp" %>
<%@ page import="cn.com.checne.model.domain.RoleInfo,cn.com.checne.model.domain.RightInfo,java.util.List,java.util.ArrayList" %>
<title>用户角色管理<c:choose><c:when test="${opt == 'update'}">修改</c:when><c:otherwise>添加</c:otherwise></c:choose></title>
<script type="text/javascript">
	$(function() {
		$("#jvForm").validate();
	});
	
	function checkForm(){
		var all_checkbox = document.getElementsByName("rightValue");
		var len = all_checkbox.length;
		if(isChecked("rightValue") == false ){
			alert('至少选择一项');
			return ;
		}
	}
</script>
</head>
<body>
<div class="body-box">
	<div class="rhead">
		<div class="rpos">当前位置: 首页 - 用户- 角色<c:choose><c:when test="${opt == 'update'}">修改</c:when><c:otherwise>添加</c:otherwise></c:choose></div>
		<div class="clear"></div>
	</div>
	<form method="post" action="${basePath}super/user/role-${opt}.do" id="jvForm" onsubmit="return checkForm();">
		<input type="hidden" id="roleId" name="roleId" value="${role.roleId}"/>
		<table width="100%" class="pn-ftable" cellpadding="2" cellspacing="1" border="0">
			<tbody>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>角色名称:</td>
				<td width="85%" class="pn-fcontent">
					<input type="text" maxlength="100" name="roleName" id="roleName" class="required" size="80" value="${role.roleName}">
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>角色描述:</td>
				<td width="85%" class="pn-fcontent">
					<textarea rows="10" cols="50" name="roleDesc" class="required" >${role.roleDesc}</textarea>
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>用户权限:</td>
				<td width="85%" class="pn-fcontent">
					<font color="red">至少选择一项</font>&nbsp;&nbsp;
					<a href="javascript:checkAll('rightValue',true);">全选</a>&nbsp;&nbsp;<a href="javascript:checkAll('rightValue',false);">取消</a>&nbsp;&nbsp;<br/><br/>
					<%
					List<String> rights = new ArrayList<String>();
					Object obj = request.getAttribute("role");
					if(obj != null){
						RoleInfo roleInfo = (RoleInfo)obj ;
						List<RightInfo> list = new ArrayList<RightInfo>();
						if(roleInfo!= null){
							list = roleInfo.getRights();
							if(list != null && list.size() > 0 ){
								for(RightInfo ri : list){
									rights.add(ri.getRightValue());
								}
							}
						}
					}
					%>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="1" <%=rights.contains("1") ? "checked" : "" %>/>&nbsp;&nbsp;公司概况</b><br/><br/>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="2" <%=rights.contains("2") ? "checked" : "" %>/>&nbsp;&nbsp;业务领域</b><br/><br/>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="3" <%=rights.contains("3") ? "checked" : "" %>/>&nbsp;&nbsp;公司业绩</b><br/><br/>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="4" <%=rights.contains("4") ? "checked" : "" %>/>&nbsp;&nbsp;信息动态</b><br/><br/>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="5" <%=rights.contains("5") ? "checked" : "" %>/>&nbsp;&nbsp;企业文化</b><br/><br/>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="6" <%=rights.contains("6") ? "checked" : "" %>/>&nbsp;&nbsp;诚聘人才</b><br/><br/>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="10" <%=rights.contains("10") ? "checked" : "" %>/>&nbsp;&nbsp;友情链接</b><br/><br/>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="7" <%=rights.contains("7") ? "checked" : "" %>/>&nbsp;&nbsp;用户中心</b><br/><br/>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="8" <%=rights.contains("8") ? "checked" : "" %>/>&nbsp;&nbsp;系统管理</b><br/><br/>
					<b><input type="checkbox" id="rightValue" name="rightValue" value="9" <%=rights.contains("9") ? "checked" : "" %>/>&nbsp;&nbsp;站外消息</b><br/><br/>
				</td>
			</tr>
			<tr>
				<td colspan="2" class="pn-fbutton">
					<input type="submit" value="提交"> &nbsp; <input type="reset" value="重置">
				</td>
			</tr>
			</tbody>
		</table>
	</form>
</div>
</body>
</html>